package cn.yogehaoren.badfox.core;

import cn.yogehaoren.badfox.struct.CommonObject;
import cn.yogehaoren.badfox.struct.Request;
import cn.yogehaoren.badfox.struct.Response;

import java.lang.annotation.Annotation;

/**
 * @author WangNing yogehaoren@gamil.com <br>
 * @since 1.0
 */
public interface BadFoxDownloadInterceptor {

    /**
     * 获取目标方法应标记的注解
     *
     * @return Annotation
     */
    public Class<? extends Annotation> getTargetAnnotationClass();

    /**
     * 当需要控制多个拦截器执行的先后顺序时可以重写这个方法
     *
     * @return 权重, 权重越大越在外层，优先拦截
     */
    public int getWeight();

    /**
     * 网络拦截器
     * @param request 请求
     * @return
     * 1. 丢弃该请求  throw IgnoreRequestException
     * 2. 修改请求    return Request
     * 3. 生成结果    return Response
     */
    CommonObject before(Request request, Response response);


    /**
     *
     * @param request 请求
     * @param response 结果
     * @return
     * 1. 丢弃该请求  throw IgnoreRequestException
     * 2. 生成结果    return Response
     */
    CommonObject after(Request request, Response response);

}
